package com.xinxin.base.converter;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.xinxin.base.util.legacy.BigDecimalUtil;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * @author ys
 * @date 2020/11/27
 */
public class BigDecimal2StringSerializer extends JsonSerializer<BigDecimal> {

    @Override
    public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString(BigDecimalUtil.formatNumber(value));
    }
}
